import Vue from 'vue'
import DictSelect from '@/common/dict/components/DictSelect'
import SelectType from './SelectType'

Vue.component('dync-control', {
  components: {
    DictSelect,
    SelectType
  },
  props: ['types', 'value', 'config'],
  render: function(h) {
    var self = this
    const { types, value, config = {} } = self
    // 下拉框配置
    const { addtype = false, lists } = config
    if (typeof types === 'undefined') {
      return h('span', value)
    }
    return h(
      types === 'dict' ? 'dict-select' : (types !== 'selects' ? 'el-' + types : 'selectType'),
      {
        props: { value, lists, addtype },
        on: {
          input: function(event) {
            self.$emit('input', event)
          }
        }
      }
    )
  }
})
